<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- 新增商品页面 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>新增商品</title>
	<script type="text/javascript" src="js\jquery-3.4.1.min.js"></script>
	<script type="text/javascript" src="js\validation.js"></script>
	<link rel="stylesheet" type="text/css" href="css\list.css">
<script type="text/javascript">
	function change() {
		var firstId = document.getElementById("fcategory").val;
		alert(firstId);
	}
	function checkSubmit(){
		//var result = true;
		var r1 = checkEmpty("#gname","#errGname");
		var r2 = checkCategory('#category','#errCategory');
		var r3 = checkPrice('#price','#errPrice');
		var r4 = checkFile('#painting','#errPainting');
		var r5 = checkEmpty('#description','#errDescription');
		if(r1 && r2 && r3 && r4 && r5){
			return true;
		}else{
			return false;
		}
	}
	function changeCategory() {
		var first_id = document.getElementById("firstCate");
		alert(first_id);
	}
</script>
</head>
<body>
	<div class="container">
		<fieldset>
			<legend>新增商品</legend>
			<form action="management?method=gcreate" method="post"
				autocomplete="off" enctype="multipart/form-data" onsubmit="return checkSubmit()">
				<ul class="ulform">
					<li>
						<span>商品名称</span>
						<span id="errPname"></span>
						<input id="gname" name="gname" onblur="checkEmpty('#gname','#errGname')"/>
					</li>
					<li>
						<span>一级分类</span>
						<span id="errFirstCategory"></span>
						<select id="fcategory" name="fcategory" onchange="change(this)">
							<option value="-1">请选择一级分类</option>
							<c:forEach items="${firstCategory}" var="first">
								<option id="firstCate" value="${first.first_cid}" >${first.first_cname}</option>
							</c:forEach>
						</select>
					</li>
					<li>
						<span>二级分类</span>
						<span id="errSecondCategory"></span>
						<select id="scategory" name="scategory" onchange="checkCategory('#scategory','#errSecondCategory')">
							<option value="-1">请选择二级分类</option>
							<c:forEach items="${secondCategory}" var="second">
								<option value="${second.first_cid}">${first.first_cname}</option>
							</c:forEach>
						</select>
					</li>
					<li>
						<span>开始时间</span>
						<span id="errStartTime"></span>
						<input type="datetime" id="stime" name="stime" onblur="checkPrice('#stime','#errStartTime')"/>
					</li>
					<li>
						<span>结束时间</span>
						<span id="errEndTime"></span>
						<input type="datetime" id="etime" name="etime" onblur="checkPrice('#etime','#errEndTime')"/>
					</li>
					<li>
						<span>起拍价</span>
						<span id="errLowPrice"></span>
						<input id="slprice" name="slprice" onblur="checkPrice('#slprice','#errLowPrice')"/>
					</li>
					<li>
						<span>加价幅度</span>
						<span id="errMarkup"></span>
						<input id="markup" name="markup" onblur="checkPrice('#markup','#errMarkup')"/>
					</li>
					<li>
						<span>评估价</span>
						<span id="errAppraisal"></span>
						<input id="appraisal" name="appraisal" onblur="checkPrice('#appraisal','#errAppraisal')"/>
					</li>
					<li>
						<span>商品预览</span>
						<span id="errPainting"></span>
						<input id="painting" name="painting" type="file" 
							style="padding-left: 0px;" accept="image/*" onchange="checkFile('#painting','#errPainting')"/>
					</li>

					<li>
						<span>商品描述</span>
						<span id="errDescription"></span>
						<textarea
							id="description" name="description" onblur="checkEmpty('#description','#errDescription')"></textarea>
					</li>
					<li style="text-align: center;">
						<button type="submit" class="btn-button">提交表单</button>
					</li>
				</ul>
			</form>
		</fieldset>
	</div>

</body>
</html>
